@include('admin.public.head')
@include('admin.public.pop')


<style type="text/css">
    .inner_btn {
        background: #19a97b;
        color: white;
        padding: 5px 8px;
        border-radius: 2px;
    }
</style>

<div class="ibox-title">
    <h5>优惠卷管理</h5>
</div>

<div class="ibox-content">
    @if(permission('/coupon_add', $user['right_list'], $user['get_routes']))
    <div class="row">
        <div class="col-sm-12 clear">
            <div class="" style="margin: 15px 10px">
                <a href="/coupon_add" class="btn btn-w-m btn-primary">新增</a>
            </div>
        </div>
    </div>
    @endif
    <div class="row">
        <div class="col-sm-12 pull-right m-b-xs">
            <form action="">
                <div class="col-sm-1  m-b-xs text-center pull-right">
                    <button type="submit" class="btn btn-sm btn-primary">搜索</button> </span>
                </div>

                <div class="col-sm-2 text-center pull-right">
                    <input type="text" name="sear_value" value="{{$sear_value}}" placeholder="兑换码" class="input form-control">
                </div>

                <div class="col-sm-1 text-center pull-right">
                    <select class="form-control" name="is_opend" >
                        <option value="">是否启用</option>
                        <option value="1" @if($is_opend == 1) selected="selected" @endif>启用</option>
                        <option value="2" @if($is_opend == 2) selected="selected" @endif>禁用</option>
                    </select>
                </div>

                @include('admin.public.store.where_select')

                @include('admin.public.common.where_time_input')

            </form>
        </div>
    </div>

    <table class="table table-bordered">
        <thead>
            <tr>
                <th>門店名稱</th>
                <th>優惠卷標題</th>
                <th>優惠卷值</th>
                <th>是否驗證過期</th>
                <th>有效期</th>
                <th>兌換碼</th>
                <th>是否啓用</th>
                <th>最大領取數</th>
                <th>已領取數</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
        @foreach ($result as $v)
            <tr>
                <td>{{$v->store->store_name??''}}</td>
                <td>{{$v->coupon_title}}</td>
                <td>{{$v->coupon_value}}</td>
                <td>
                    @if($v->is_expiration == 1)是@endif
                    @if($v->is_expiration == 2)否@endif
                </td>
                <td>
                    {{$v->expiration_time}}
                </td>
                <td>
                    {{$v->coupon_code}}
                </td>
                <td>
                    @if($v->is_opend == 1)是@endif
                    @if($v->is_opend == 2)否@endif
                </td>
                <td>
                    {{$v->max_number}}
                </td>
                <td>
                    {{$v->received_count}}
                </td>
                <td>
                    @if(permission('/coupon_edit', $user['right_list'], $user['get_routes']))
                    <div class="btn-group">
                        <a  class="btn btn-primary btn-sm dropdown-toggle" href="/coupon_edit/{{$v->id}}">編輯
                        </a>&nbsp;&nbsp;
                    </div>
                    @endif

                    @if(permission('/coupon_del', $user['right_list'], $user['get_routes']))
                    <div class="btn-group">
                        <a  class="btn btn-primary btn-sm dropdown-toggle" href="javascript:void(0)" onclick="del($(this))" url="/coupon_del/{{$v->id}}">刪除
                        </a>&nbsp;&nbsp;
                    </div>
                    @endif

                    @if(permission('/recipients', $user['right_list'], $user['get_routes']))
                        <div class="btn-group">
                            <a  class="btn btn-primary btn-sm dropdown-toggle" href="/recipients/{{$v->id}}">查看兑换记录
                            </a>&nbsp;&nbsp;
                        </div>
                    @endif
                </td>
            </tr>
        @endforeach
        </tbody>
        {{ $result->appends(Request::except('page'))->links() }}
    </table>
    {{ $result->appends(Request::except('page'))->links() }}
</div>

